﻿@model CodeGeneratorLibrary.Options

@{
    ViewBag.Title = "Edit";
		CodeGeneratorLibrary.Options options = Model;
		
}

<h2>Edit</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<script type="text/javascript">
	$().ready(function () {
		$('input#Word').change(function () {
			$('a#word-link').attr('href', '@Url.Action("Word")' + '/'+ $(this).val());
		});
	});
</script>

<script type="text/javascript">
	$().ready(function () {
		$('a#test-link').click(function () {

			var data = {
				user: [{
					name: 'cn',
					last_name: 'Иванов',
					href: [{ 
						name: [{ 0: 'Microsoft', 1: 'Yandex'}],
						href: [{ 0: 'http://microsoft.com', 1: 'http://yandex.ru'}]
					}]
				}],
				company: [{ name: 'Рога и копыта'}]
			};

			$.ajax({
				type: "POST",
				url: "some.php",
				data: data,
				success: function (msg) {
					alert("Data Saved: " + msg);
				}
			});
			return false;
		});
	});
</script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Options</legend>
        <div class="editor-label">
            @Html.LabelFor(m => m.ConnectionString)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(m => m.ConnectionString, new {style = "width:100%"})
            @Html.ValidationMessageFor(m => m.ConnectionString)
        </div>

        <div class="editor-label">
            @Html.LabelFor(m => m.TableToGenerate)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(m => m.TableToGenerate, new { style = "width:100%" })
            @Html.ValidationMessageFor(m => m.TableToGenerate)
						@Html.ActionLink("Word", "Word", "Options", new { word = options.TableToGenerate }, new { Id = "word-link", target = "blank" })
        </div>

        <div class="editor-label">
            @Html.LabelFor(m => m.AuthorName)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(m => m.AuthorName, new { style = "width:100%" })
            @Html.ValidationMessageFor(m => m.AuthorName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(m => m.SqlOperation)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(m => m.SqlOperation, new { style = "width:100%" })
            @Html.ValidationMessageFor(m => m.SqlOperation)
        </div>


        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
	@Html.ActionLink("Test", "Index", "Home", new { }, new { id = "test-link" });
</div>

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

